//
//  NewsView.m
//  BasketballClub
//
//  Created by 孙鸿吉 on 16/1/6.
//  Copyright © 2016年 孙鸿吉. All rights reserved.
//

#import "NewsView.h"

@implementation NewsView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self allViews];
    }
    return self;
}

-(void)allViews
{
    
    //设置scrollview
    self.scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44*LAYOUT_SIZE_HEIGHT, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    self.scrollview.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width*2, 0);
    //整屏滑动
    self.scrollview.pagingEnabled = YES;
    //边界不能拖拽
    self.scrollview.bounces = NO;
    [self addSubview:self.scrollview];
    //NBA Tableview
    self.newsNBATableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 414*LAYOUT_SIZE, CGRectGetHeight(self.scrollview.frame)-44*LAYOUT_SIZE_HEIGHT) style:UITableViewStylePlain];
    [self.scrollview addSubview:self.newsNBATableView];
    
    //CBA Tableview
    self.newsCBATableView = [[UITableView alloc] initWithFrame:CGRectMake(414*LAYOUT_SIZE, 0, 414*LAYOUT_SIZE, CGRectGetHeight(self.scrollview.frame)-44*LAYOUT_SIZE_HEIGHT) style:UITableViewStylePlain];
    [self.scrollview addSubview:self.newsCBATableView];
    
    
    //置顶按钮
    self.btn_top = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.btn_top setImage:[UIImage imageNamed:@"iconfont-mianxingtubiaozhiding@2x"] forState:UIControlStateNormal];
    self.btn_top.tintColor = [UIColor yellowColor];
    self.btn_top.frame = CGRectMake(350*LAYOUT_SIZE, 600*LAYOUT_SIZE_HEIGHT, 50*LAYOUT_SIZE, 50*LAYOUT_SIZE_HEIGHT);
    self.btn_top.hidden =YES;
    [self bringSubviewToFront:self.btn_top];
    [self addSubview:self.btn_top];
    
    //设置左边按钮nba
    self.newsCustomNaviBarView = [[UIView alloc]  initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64*LAYOUT_SIZE_HEIGHT)];
    self.newsCustomNaviBarView.backgroundColor = ColorHex(0x0d1c38);
    [self addSubview:self.newsCustomNaviBarView];
    
    //左边按钮nba
    self.leftButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    if ( self.leftButton  != nil) {
        self.leftButton .frame = CGRectMake(60*LAYOUT_SIZE, 10*LAYOUT_SIZE_HEIGHT, 90*LAYOUT_SIZE, 64*LAYOUT_SIZE_HEIGHT);
        //button的title
        [ self.leftButton  setTitle:@"NBA" forState:UIControlStateNormal];
        //button的字体大小
        self.leftButton .titleLabel.font = [UIFont systemFontOfSize:30.0*LAYOUT_SIZE];
        //button的字体颜色
        self.leftButton .tintColor = [UIColor yellowColor];
        //对齐方式
        self.leftButton .contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        
        [self.newsCustomNaviBarView addSubview: self.leftButton];
        
    }
    
    //设置右边按钮cba
    self. rightButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    if (self. rightButton != nil) {
        [self. rightButton setFrame:CGRectMake(270*LAYOUT_SIZE, 10*LAYOUT_SIZE_HEIGHT, 90*LAYOUT_SIZE, 64*LAYOUT_SIZE_HEIGHT)];
        //button的title
        [self. rightButton setTitle:@"CBA" forState:UIControlStateNormal];
        //button的字体大小
        self. rightButton.titleLabel.font = [UIFont systemFontOfSize:26.0*LAYOUT_SIZE];
        //button的字体颜色
        self. rightButton.tintColor = [UIColor whiteColor];
        //对齐方式
        self. rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        
        [self.newsCustomNaviBarView addSubview:self. rightButton];
        
        
    }
    
}




@end
